import { studentApi, teacherApi } from '@/services/api-common';
import Add from '../components/AddEdit/Add.js';
import items1 from './items1.js';
import items2 from './items2.js';

function setup() {
	this.add({
		is: $TableTabs,
		tables: [{
			items: items1,
			tabTitle: '学生信息',
			httpApi: studentApi.list,
			httpKey: studentApi.listKey,
			container(midder) {
				return {
					title: '学生列表',
					extra: {
						midder,
						is: 'TableTools',
						buttons: [{
							type: 'primary',
							text: '新增',
							onClick: () => {
								midder.open(Add, async (data, close) => {
									await studentApi.add(data);
								}, {
									type: 'add',
									param: { class: 'no-padding' },
								});
							}
						}]
					}
				}
			},
			filter(midder) {
				return { is: 'ExpandFilter', midder }
			},
		}, {
			items: items2,
			tabTitle: '老师信息',
			httpApi: teacherApi.list,
			httpKey: teacherApi.listKey,
			container(midder) {
				return {
					title: '老师列表',
					extra: {
						midder,
						is: 'TableTools',
						buttons: [{
							type: 'primary',
							text: '新增',
							onClick: () => {
								midder.open(Add, async (data, close) => {
									await teacherApi.add(data);
								}, {
									type: 'add',
									param: { class: 'no-padding' },
								});
							}
						}]
					}
				}
			},
			filter(midder) {
				return {
					is: 'TableFilter',
					title: '筛选区2',
					midder
				}
			},
		}]
	})
}
export default setup;